package cn.com.tt.flink.sql.engine.strategy;

import cn.com.tt.flink.sql.engine.pojo.source.SourceProperty;

import java.util.List;
import java.util.Optional;

/**
 * 用于校验属性是否存在
 */
public class PropertyValidator {
    List<SourceProperty> propertyList;

    public PropertyValidator(List<SourceProperty> propertyList) {
        this.propertyList = propertyList;
    }

    public void vaild(String proName, String exceptionMsg) throws Exception {
        Optional<SourceProperty> connector = propertyList.stream().filter(p -> p.getPropKey().equals(proName)).findFirst();
        connector.orElseThrow(() -> new Exception(exceptionMsg));
    }
}
